package com.zjj.concurrent.completableFuture;

import java.util.Random;
import java.util.concurrent.CompletableFuture;

/**
 * @author zhanglei.zjj
 * @description CompletableFuture使用ThenAccept消费数据，这个接口只有输入，没有返回值
 * @date 2023/6/4 14:54
 */
public class ThenAcceptTest {
    public static void main(String[] args) {
        CompletableFuture<Void> future = CompletableFuture
                .supplyAsync(() -> {
                    int number = new Random().nextInt(10);
                    System.out.println("第一阶段：" + number);
                    return number;
                }).thenAccept(number ->
                        System.out.println("第二阶段：" + number * 5));
        System.out.println(future.join());
    }
}
